package com.sunday.member.ui;

import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.sunday.member.R;
import com.sunday.member.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * Created by wang on 2016/3/25.
 */
public class WebViewActivity extends BaseActivity {

    TextView titleView;
    WebView webView;

    private String url;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        titleView = ButterKnife.findById(this,R.id.title_view);
        webView = ButterKnife.findById(this,R.id.web_view);
        url = getIntent().getStringExtra("url");
        String title = getIntent().getStringExtra("title");
        if(!TextUtils.isEmpty(title)){
            titleView.setText(title);
        }
        WebSettings webSettings =   webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(false);
        webSettings.setSupportZoom(false);
        webView.setWebViewClient(new WebViewClient(){
            // 这个方法在用户试图点开页面上的某个链接时被调用
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if(url!=null) {
                    view.loadUrl(url);
                }
                return true;
            }
        });
        webView.loadUrl(url);
    }
}
